home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcoop.arc / TCOOP2.ARC / FSOUNIT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  2.6 KB  |  116 lines

  1. // fsounit.cpp: FSO Class Implementation
  2.  
  3. #include "fsounit.h"
  4.  
  5. Fso::Fso(int Ba, int Fa, ColorPak &Cp)
  6. // Sets up the frame and border attributes and assigns the three
  7. // Rso's (Frame, Interior, and Overall) to NULL. The Rso's should be 
  8. // initialized by a derived class. 
  9. {
  10.   Bwd      = Ba & 0x000f;        // Unpack the border width 
  11.   Bstyle   = (Ba >> 4) & 0x000f; // and the border type     
  12.   Fattr    = Fa;
  13.   Colors   = Cp;
  14.   Frame    = NULL;               // Must be set by derived 
  15.   Interior = NULL;               // class
  16.   Overall  = NULL;
  17. }
  18.  
  19. int Fso::IsSwappable(void) { return (Fattr & Swappable) != 0; }
  20.  
  21. int Fso::IsCloseable(void) { return (Fattr & Closeable) != 0; }
  22.  
  23. int Fso::IsStretchable(void) 
  24. {
  25.   return (Fattr & Stretchable) && IsSwappable(); 
  26. }
  27.  
  28. int Fso::HasShadow(void) { return (Fattr & AnyShadow) != 0; }
  29.  
  30. int Fso:: OnFrame(int X, int Y)
  31.   return Frame->Contains(X, Y); 
  32. }
  33.  
  34. int Fso::OnInterior(int X, int Y)
  35.   return Interior->Contains(X, Y); 
  36. }
  37.  
  38. int Fso::OnBorder(int X, int Y)
  39.   return Frame->Contains(X,Y) && !Interior->Contains(X,Y); 
  40. }
  41.  
  42. int Fso::OnCloseButton(int /*X*/, int /*Y*/)
  43. // Checks to see if the location X,Y resides on close button.
  44. // Fso's don't have a close button, but a derived type might.
  45. {
  46.   return False;
  47. }
  48.  
  49. int Fso::Touches(Fso *F) 
  50.   return Overall->Touches(F->Overall); 
  51. }
  52.  
  53. // The following screen transfer routines use the interior 
  54. // rectangle. Also, the attributes can be defaulted to their 
  55. // stored values.
  56.  
  57. void Fso::Scroll(ScrollDir Sd, int Amt) 
  58.   Interior->Scroll(Sd, Amt); 
  59. }
  60.  
  61. void Fso::HzWrt(int X, int Y, char *Str, char Attr)
  62. {
  63.   if (Attr == 0) Attr = Colors.Wc;
  64.   Interior->HzWrt(X, Y, Str, Attr);
  65. }
  66.  
  67. void Fso::HzWrtB(int X, int Y, char *Str)
  68.   Interior->HzWrtB(X,Y,Str); 
  69. }
  70.  
  71. void Fso::Fill(int X, int Y, int W, int H, char Ch, char Attr)
  72. {
  73.   if (Attr == 0) Attr = Colors.Wc;
  74.   Interior->Fill(X, Y, W, H, Ch, Attr);
  75. }
  76.  
  77. void Fso::FillB(int X, int Y, int W, int H, char Ch, char Opt)
  78. {
  79.   Interior->FillB(X, Y, W, H, Ch, Opt);
  80. }
  81.  
  82. void Fso::Box(int X, int Y, int W, int H,  char Ba, char Attr)
  83. {
  84.   if (Attr == 0) Attr = Colors.Bc;
  85.   if (Ba == 0) Ba = (Bstyle << 4) + Bwd;
  86.   Interior->Box(X, Y, W, H, Ba, Attr);
  87. }
  88.  
  89. // The default arrangement is for the rectangles to be on 
  90. // top of one another as given in these default SetSize and 
  91. // SetLocn routines
  92.  
  93. void Fso::SetSize(int W, int H) 
  94. {
  95.   Interior->SetSize(W, H);
  96.   Frame->SetSize(W, H);
  97.   Overall->SetSize(W, H);
  98. }
  99.  
  100. void Fso::SetLocn(int Xl, int Yl) 
  101. {
  102.   Frame->SetLocn(Xl, Yl);
  103.   Overall->SetLocn(Xl, Yl);
  104.   Interior->SetLocn(Xl, Yl);
  105. }
  106.  
  107.  
  108.  
  109.  
  110.